<template>
  <div>
    用户发布信息审核

    <el-table :data="invitation.data">
      <el-table-column
        label="id"
        prop="invitation_id"
        width="55"
        align="center"
      ></el-table-column>
      <el-table-column
        label="信息标题"
        prop="invitation_title"
        align="center"
        :show-overflow-tooltip="true"
      ></el-table-column>
      <el-table-column
        label="信息内容"
        prop="invitation_content"
        align="center"
        :show-overflow-tooltip="true"
      ></el-table-column>
      <el-table-column
        label="发布时间"
        prop="invitation_time"
        align="center"
        width="160"
      ></el-table-column>
      <el-table-column
        label="用户id"
        prop="user_id"
        align="center"
        width="80"
      ></el-table-column>
      <el-table-column label="发布状态" prop="invitation_state" align="center">
        <template slot-scope="scope">
          <div v-if="scope.row.invitation_state == 0">
            <el-button type="success" @click="pass(scope.row.invitation_id)">通过</el-button>
            <el-button type="danger" @click="overrule(scope.row.invitation_id)">不通过</el-button>
          </div>
          <div v-else>已审核</div>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      style="margin-top: 20px"
      background
      layout="->, total, prev, pager, next, jumper"
      :total="total"
      :page-size="pagesize"
      :current-page="page"
      @current-change="changeCurrentPage($event)"
    >
    </el-pagination>
  </div>
  
</template>

<script>
import httpApi from "@/http";
export default {
  data() {
    return {
      invitation: {},
      total:'',
      page:'',
      pagesize:''
    };
  },
  methods: {
    list(num) {
      httpApi.invitationApi.listByHt({ page: num, pagesize: 10 }).then((res) => {
        console.log(res);
        this.invitation = res.data;
        this.total = res.data.total;
        this.page = parseInt(res.data.page);
        this.pagesize = parseInt(res.data.pagesize);
        console.log('page',this.page)
      });
    },
    pass(id){
        this.$confirm("将通过审核, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "success",
      }).then(()=>{
        httpApi.invitationApi.state({invitation_id:id,invitation_state:1}).then(res=>{
            console.log(res)
            this.list(1)
        })
      })
        
    },
        overrule(id){
        this.$confirm("将拒绝通过, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "danger",
      }).then(()=>{
        httpApi.invitationApi.state({invitation_id:id,invitation_state:2}).then(res=>{
            console.log(res)
            this.list(1)
        })
      })
        
    },
    changeCurrentPage(page) {
        this.list(page);
      
    },
  },
  mounted() {
    this.list(1);
  },
};
</script>

<style lang="scss" scoped>
</style>